home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8705 < prev    next >
Encoding:
Text File  |  1996-08-05  |  950 b   |  36 lines

  1. Path: tst.hk.super.net!moscow
  2. From: moscow@news.hk.super.net (Peter Alexander Schindler)
  3. Newsgroups: comp.lang.c++
  4. Subject: Access COM port in MSVC++4.0
  5. Date: 26 Feb 1996 04:00:10 GMT
  6. Organization: Hong Kong Supernet
  7. Message-ID: <4grb8a$kaf@tst.hk.super.net>
  8. NNTP-Posting-Host: is3.hk.super.net
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. Has anybody tried to access COM ports using the API in MSVC++4.0?  I have 
  12. been having troubles using the WriteFile() function.  The code I write is 
  13. like this:
  14.  
  15.     HANDLE hCom;
  16.     char *buffer = "xxx";
  17.     LPDWORD lpNumOfBytesWritten;
  18.  
  19.     hCom = CreateFile("COM2", GENERIC_READ|GENERIC_WRITE
  20.             0, NULL , OPEN_EXISTING, 0, NULL);
  21.  
  22.     /* check error here, and things are ok */
  23.     /* set comm parameters */
  24.  
  25.     WriteFile(hCom, (LPCVOID)&buffer, sizeof(buffer),
  26.         lpNumOfBytesWritten, NULL);
  27.  
  28. The error ERROR_INVALID_PARAMETER results in the call to WriteFile().  
  29. Can anybody offer me some hints?  Thanks in advance.
  30.  
  31.  
  32. Rgds,
  33. Winnie
  34.  
  35.  
  36.